#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<random>
#include<string>
#include<time.h>
#include<map>
#include<set>
#include"MySet.h"
#include"MyMap.h"
using namespace std;


void set_test()
{
	xsc::set<int> self_tree;
	set<int> tree;
	srand((unsigned)time(NULL));
	int begin = clock();
	for (int i = 0; i < 10000000; ++i)
	{
		tree.insert(rand() % 10000000);
	}
	int end = clock();
	cout << endl << "set库使用时间：" << end - begin<<endl;
	begin = clock();
	for (int i = 0; i < 10000000; ++i)
	{
		self_tree.insert(rand() % 10000000);
	}
	end = clock();
	cout << endl << "set自实现使用时间：" << end - begin<<endl;
}

void map_test()
{
	xsc::map<int,int> self_tree;
	/*map<int,int> tree;
	srand((unsigned)time(NULL));
	int begin = clock();
	for (int i = 0; i < 10000000; ++i)
	{
		tree[rand() % 10000000] =  rand() % 10000000;
	}
	int end = clock();
	cout << endl << "map库使用时间：" << end - begin<<endl;*/
	int begin = clock();
	for (int i = 0; i < 10000000; ++i)
	{
		self_tree.insert(make_pair(rand() % 10000000, rand() % 10000000));
	}
	int end = clock();
	cout << endl << "map自实现使用时间：" << end - begin << endl;

}

int main()
{
	//map_test();
	//set_test();
	xsc::map<int,int> test;
	srand((unsigned)time(0));
	//test["954783"] = "456789";
	//for (int i = 0; i < 1000; i++)
	//{
	//	test[rand() % 1000000] = rand() % 1000000;
	//}
	//int count = 0;
	//for (auto e : test)
	//{
	//	cout << e.first << ":" << e.second << endl;
	//	count++;
	//}
	//cout << "count:" << count;
	test.insert(make_pair(1, 2));
	test.insert(make_pair(2, 3));
	test.insert(make_pair(3, 4));
	test.insert(make_pair(4, 5));
	xsc::map<int, int> copy(test);
	copy.insert(make_pair(5, 6));
	copy.insert(make_pair(6,7));
	copy.insert(make_pair(7,8));
	copy.insert(make_pair(8,9));
	copy.insert(make_pair(9,10));
	copy.insert(make_pair(10,11));
	auto it = copy.begin();
	while (it != copy.end())
	{
		cout << it->first << ":" << it->second << endl;
		it++;
	}
	return 0;
}